﻿@using RooHui.Infrastructure.Entities.Entity;
@using RooHui.Infrastructure.Entities.Enum
@using RooHui.Tool
@{
    ViewBag.Title = "MemeberDetail";
    Layout = "~/Views/Shared/_Base.cshtml";
    Member member = ViewBag.member;
}
<input type="hidden" name="memerName" id="memerName" value="@member.UserName" />
<div style="text-align: right;">
    <input type="button" value="返回" id="btnCancel" class="btn btn-primary btn-small" /></div>
<div style="width: 99%; height: 1px; overflow: hidden; background-color: #dddddd;
    margin: 10px">
</div>
<div class="widget widget-table">
    <div class="widget-header">
        <h3>
            基本信息</h3>
    </div>
    <div class="widget-content">
        <table border="0" width="100%" class="tablel">
            <tr>
                <td align="right" width="80px">
                    用户名:
                </td>
                <td align="left" width="200px">
                    @member.UserName
                </td>
                <td align="right" width="80px">
                    真实姓名:
                </td>
                <td align="left" width="200px">
                    @member.RealName
                </td>
                <td align="right" width="80px">
                    认证情况:
                </td>
                <td align="left" width="250px">
                    @{
                        if (member.IDCardCheck)
                        {
                        <span class="label label-info"><i class="icon-user label-info"></i>已实名</span>
                        }
                        else
                        {
                        <span class="label"><i class="icon-user"></i>未实名</span>
                        }

                        if (member.HandPhoneCheck)
                        {
                        <span class="label label-info"><i class="icon-mobile-phone label-info"></i>手机已认证</span>
                        }
                        else
                        {
                        <span class="label"><i class="icon-mobile-phone"></i>手机未认证</span>
                        }

                        if (member.EmailCheck)
                        {
                        <span class="label label-info"><i class="icon-envelope label-info"></i>邮箱已认证</span>
                        }
                        else
                        {
                        <span class="label"><i class="icon-envelope"></i>邮箱未认证</span>
                        }
                            
                       
                    }
                </td>
                <td align="right" width="80px">
                    会员类型:
                </td>
                <td align="left" width="200px">
                    @member.MemberType.Mapping()
                </td>
            </tr>
            <tr>
                <td align="right">
                    邮箱:
                </td>
                <td>
                    @member.Email
                </td>
                <td align="right">
                    手机号:
                </td>
                <td>
                    @member.HandPhone
                </td>
                <td align="right">
                    身份证:
                </td>
                <td>
                    @member.IDCardNo
                </td>
                <td align="right">
                    是否激活:
                </td>
                <td>
                    @{
                        if (member.IsActive)
                        {
                        <span class="label label-info">已激活</span>
                        }
                        else
                        {
                        <span class="label">未激活</span>
                        }
                    }
                </td>
            </tr>
            <tr>
                <td align="right">
                    性别:
                </td>
                <td>
                    @member.Gender.Mapping()
                </td>
                <td align="right">
                    注册IP:
                </td>
                <td>
                    @member.RegisterIP
                </td>
                <td align="right">
                    住址:
                </td>
                <td colspan="3">
                    @member.Address
                </td>
            </tr>
            <tr>
                <td align="right">
                    注册方式:
                </td>
                <td>
                    @{
                        if (member.CreateType == CreateType.Normal)
                        {
                        <span>网站注册</span>
                        }
                        else
                        {
                        <span>后台创建</span>
                        }
                    }
                </td>
                <td align="right">
                    注册时间:
                </td>
                <td>
                    @member.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")
                </td>
                <td align="right">
                    注册人:
                </td>
                <td>
                    @{
                        if (member.CreateType == CreateType.Mortgagor)
                        {
                        <span>@member.User.RealName</span>
                        }
                    }
                </td>
                <td align="right">
                    用户状态:
                </td>
                <td>
                    @{
                        if (member.Status == ItemStatus.Enable)
                        {
                        <span>正常</span>
                        }
                        else
                        {
                        <span>禁用</span>
                        }
                    }
                </td>
            </tr>
            <tr>
                <td colspan="8">
                </td>
            </tr>
            @{
                if (member.MemberType == MemberType.Invester || member.MemberType == MemberType.Borrower)
                {
                    if (member.Account != null)
                    {
            
                <tr>
                    <td align="right" width="80px">
                        资金账户:
                    </td>
                    <td align="left" width="200px">
                        @member.Account.AccountNo
                    </td>
                    <td align="right" width="80px">
                        资金平台:
                    </td>
                    <td align="left" width="200px">
                        @{
                        if (member.Account.Platfrom == 0)
                        {
                            <span>汇付天下</span>
                        }
                        }
                    </td>
                    <td align="right" width="80px">
                        账户余额:
                    </td>
                    <td align="left" width="250px">
                        <span style="color: #0078ff; font-size: 26px; font-weight: bolder;">&yen @member.Account.BalanceAmount.ToString("f2")</span>
                    </td>
                    <td align="right" width="80px">
                        冻结资金:
                    </td>
                    <td align="left" width="200px">
                        <span style="color: #0078ff; font-size: 26px; font-weight: bolder;">&yen @member.Account.FrozenAmount.ToString("f2")</span>
                    </td>
                </tr>
                
                    }

                }
                if (member.MemberType == MemberType.Agent)
                {
             
                <tr>
                    <td align="right" width="80px">
                        经纪人编号:
                    </td>
                    <td align="left" width="200px">
                        @member.AgentInfo.AgentCode
                    </td>
                    <td align="right" width="80px">
                        结算方式:
                    </td>
                    <td align="left" width="200px">
                        @member.AgentInfo.SettlementType.Mapping()
                    </td>
                    <td align="right" width="80px">
                        结算值:
                    </td>
                    <td align="left" width="250px">
                        @{
                    if (member.AgentInfo.SettlementType == 0)
                    {
                            <span style="color: #0078ff; font-size: 26px; font-weight: bolder;">@member.AgentInfo.Settlement
                                %</span><span>/笔</span>
                    }
                    else
                    {
                            <span style="color: #0078ff; font-size: 26px; font-weight: bolder;">&yen @member.AgentInfo.Settlement</span><span>/笔</span>
                    }
                        }
                    </td>
                    <td align="right" width="80px">
                        总收益:
                    </td>
                    <td align="left" width="200px">
                    </td>
                </tr>
                }
            }
        </table>
    </div>
</div>
@{
    if (member.MemberType == MemberType.Agent)
    {
    <div class="widget widget-table" style="margin-top:5px">
        <div class="widget-header">
            <h3>
                收益结算</h3>
        </div>
        <div class="widget-content" style="border:1px solid #dddddd">
            <div style="text-align: right;margin-right:10px">
                <input type="text" id="txtBeginDate" readonly="readonly" style="margin-top: 10px" value="@DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd")"
                    onfocus="WdatePicker({isShowClear:false, readOnly:true,skin:'ext',dateFmt:'yyyy-MM-dd'})"
                    placeholder="起始日期" class="Wdate" />至
                <input type="text" id="txtEndDate" readonly="readonly" style="margin-top: 10px" value="@DateTime.Now.ToString("yyyy-MM-dd")"
                    onfocus="WdatePicker({isShowClear:false, readOnly:true,skin:'ext',dateFmt:'yyyy-MM-dd'})"
                    placeholder="结束日期" class="Wdate" />
                <button class="btn btn-primary btn-small" id="btnSearch">
                    查询
                </button>
            </div>
            <table id="agentProfitgrid" class="mmg" width="100%">
                <tr>
                    <th rowspan="" colspan="">
                    </th>
                </tr>
            </table>
            <div id="pg" style="text-align: right;">
            </div>
        </div>
    </div>
        
    }

}
<div style="width: 99%; height: 1px; overflow: hidden; background-color: #dddddd;
    margin: 10px">
</div>
<div style="text-align: right">
    <input type="button" value="返回" id="btnCancelbottom" class="btn btn-primary btn-small" /></div>
@section tail{
    <script src="/content/plugins/mmgrid/mmGrid.js" type="text/javascript"></script>
    <script src="/content/plugins/mmgrid/mmPaginator.js" type="text/javascript"></script>
    <script type="text/javascript">
        var cols = [
            { title: '类型', name: 'Type', width: 20, align: 'center', renderer: function (val, item, index) {
                if (item["Type"] == 0) { return "收益" }
                return "结算";
            }
            },
            { title: '投资人', name: 'RealName', width: 50, align: 'center', renderer: function (val, item, index) {

                return item["InvesterUser"]["RealName"];
            }
            },
            { title: '投资项目', name: 'ProjectTitle', width: 80, align: 'center', renderer: function (val, item, index) {

                return item["Investment"]["Project"]["ProjectTitle"];
            }
            },

            { title: '投资金额', name: 'InvestMentAmount', width: 30, align: 'center', renderer: function (val, item, index) {
                if (item["Type"] == 0) {
                    return "&yen" + Number(item["Investment"]["InvestMentAmount"]).toFixed(2);
                }
            }
            },
            { title: '结算方式', name: 'SettlementType', width: 40, align: 'center', renderer: function (val, item, index) {
                if (item["SettlementType"] == 0) { return '按比例'; }
                else if (item["SettlementType"] == 1) return '固定值';
            }
            },
            { title: '结算值', name: 'Settlement', width: 40, align: 'center', renderer: function (val, item, index) {
                if (item["Type"] == 0) {
                    if (item["SettlementType"] == 0) return item["Settlement"] + "%";
                    return "&yen" + Number(item["Settlement"]).toFixed(2);
                }
            }
            },
            { title: '金额', name: 'Profit', width: 80, align: 'center', renderer: function (val, item, index) {

                return "&yen" + Number(item["Profit"]).toFixed(2);
            }
            },
            { title: '时间', name: 'RecordDate', width: 80, align: 'center', renderer: function (val, item, index) {
                val = val.replace("T", " ");
                return val;
            }

            }
         ];
        var agentGrid;
        $(function () {
            $("#btnCancel").click(function () { location.href = decodeURIComponent("@Html.Raw(ViewBag.backUrl)"); });

            $("#btnCancelbottom").click(function () {
                location.href = decodeURIComponent("@Html.Raw(ViewBag.backUrl)");
            });
            
            agentGrid = $('#agentProfitgrid').mmGrid({
                indexCol: true,
                indexColWidth: 25,
                height: 400,
                cols: cols,
                params: { startDate: $("#txtBeginDate").val(), endDate: $("#txtEndDate").val(), agentUserName: $("#memerName").val()},
                url: '/Member/GetAgentProfitListByPage',
                method: 'get',
                remoteSort: true,
                multiSelect: false,
                checkCol: false,
                fullWidthRows: true,
                autoLoad: false,
                plugins: [
                        $('#pg').mmPaginator()
                    ]
            });
            agentGrid.load()
            $("#btnSearch").click(function () {

                search();

            });
        });
        function search() {
            agentGrid.setParm({ startDate: $("#txtBeginDate").val(), endDate: $("#txtEndDate").val(), agentUserName: $("#memerName").val() });
            agentGrid.load({ page: 1 });
        }
    </script>
}
